package com.itheima.subway.info.manage.service;

import com.itheima.subway.info.manage.dao.CheckDao;
import com.itheima.subway.info.manage.domain.Subways;

import java.util.ArrayList;

public class CheckService {

    static ArrayList<Subways> subways = CheckDao.getSubways();

    //判断地铁站是否存在
    public static boolean isExists(String next) {
        boolean flag = false;
        for (Subways subway : subways) {
//            System.out.println(subway);
            if (subway.getSubName().equals(next)) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    //获取对应地铁站的对象
    public static Subways getSubway(String next) {
        Subways sub = null;
        for (Subways subway : subways) {
            if (subway.getSubName().equals(next)) {
                sub = subway;
                break;
            }
        }
        return sub;
    }
}
